package day04;

public class Addition {
    public static void main(String[] args) {
        //累加和1+2+3+4+...+99+100
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum = sum + i;
        }
        System.out.println("sum=" + sum);
        /*
        执行过程
                sum=0
        i=1     sum=0+1
        i=2     sum=1+2
        i=3     sum=1+2+3
        i=4     sum=1+2+3+4
        ...     sum=1+2+3+4+...
        i=99    sum=1+2+3+4+...+99
        i=100   sum=1+2+3+4+...+99+100
         */
    }
}
